<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 微信素材扩展表（图片、视频、音频、音乐扩展）
 */
class CreateWxMaterialExt extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wx_material_exts', function (Blueprint $table) {
            $table->increments('id')->comment('自增序号');
            $table->unsignedInteger('material_id')->default(0)->comment('素材主键');
            $table->string('title', 150)->default('')->comment('标题');
            $table->mediumText('description')->comment('描述');
            $table->string('music_url', 200)->default('')->comment('音乐链接');
            $table->string('hq_music_url', 200)->default('')->comment('高质量音乐链接');
            $table->unsignedInteger('file_id')->default(0)->comment('文件ID，对应sys_files表主键');
            $table->string('view_url',200)->default('')->comment('访问地址');
            //音乐素材字段
            $table->unsignedInteger('thumb_material_id')->default(0)->comment('封面图素材主键');
            $table->string('thumb_media_id', 150)->default('')->comment('封面图素材ID');
            $table->string('thumb_view_url', 200)->default('')->comment('封面图访问地址');
            $table->softDeletes();
            $table->timestamps();
            $table->index(['material_id','deleted_at'], 'index1');
            $table->index(['view_url','deleted_at'], 'index2');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_material_exts');
    }
}
